    $(document).ready(function () {
    	var context = {
    		links: [
    			/*{
    				name: "Dashboard",
    				href: "#",
    				load: "../user/user_dashboard.html",
    				parentId: 0,
    				id: 1,
    				class: "fa fa-bar-chart-o blue"
                            }, {
    				name: "Courses",
    				href: "#",
    				load: "../course/courseoffering_main.html",
    				parentId: 0,
    				id: 2,
    				class: "fa fa-eye blue"
                            }, {
    				name: "Add Course Offering",
    				href: "#",
    				load: "../course/courseoffering_wizard.html",
    				parentId: 2,
    				id: 8,
    				class: "fa fa-eye blue"
                            }, {
    				name: "Subscribed Courses",
    				href: "#",
    				load: "../course/courseoffering_subscribed.html",
    				parentId: 2,
    				id: 9,
    				class: "fa fa-eye blue"
                            },*/
    			{
    				name: "Tests",
    				href: "#",
    				parentId: 0,
    				id: 3,
    				class: "fa fa-dashboard blue"
                },
    			{
    				name: "Home",
    				href: "#",
    				load: "../test/test_home.html",
    				parentId: 3,
    				id: 444,
    				class: "fa fa-dashboard blue"
                },
    			{
    				name: "Repository",
    				href: "#",
    				load: "../test/test_repository.html",
    				parentId: 3,
    				id: 999,
    				class: "fa fa-dashboard blue"
                },
    			{
    				name: "Subscribed Tests",
    				href: "#",
    				load: "../test/tests_subscribed.html",
    				parentId: 3,
    				id: 22,
    				class: "fa fa-dashboard blue"
                 },
    			{
    				name: "Create Test",
    				href: "#",
    				load: "../test/create_test_wizard.html",
    				parentId: 3,
    				id: 23,
    				class: "fa fa-dashboard blue"

				},
    			{
    				name: "Reports",
    				href: "#",
    				load: "../test/test_reports.html",
    				parentId: 3,
    				id: 295,
    				class: "fa fa-dashboard blue"

				},
    			{
    				name: "Profile",
    				href: "#",
    				load: "../test/test_profile.html",
    				parentId: 3,
    				id: 297,
    				class: "fa fa-dashboard blue"

				},

    		/*	{
    				name: "Resources",
    				href: "#",
    				load: "../resource/resource_upload.html",
    				parentId: 0,
    				id: 4,
    				class: "fa fa-bar-chart-o blue"
                            }, {
    				name: "View",
    				href: "#",
    				load: "../resource/resource_listing.html",
    				parentId: 4,
    				id: 5,
    				class: "fa fa-dashboard blue"
                            }*/
			]
    	};

    	var links = context.links;
    	var parentIds = new Array();
    	var parentChildMap = {};
    	var counter = 0;
    	for (var i = 0; i < links.length; i++) {
    		var currentParentId = links[i].parentId;
    		if (currentParentId != 0 && parentIds.indexOf(currentParentId) == -1) {
    			parentIds[counter++] = currentParentId;
    			parentChildMap[currentParentId] = new Array();
    			parentChildMap[currentParentId].push(links[i]);
    		} else if (currentParentId != 0 && parentIds.indexOf(currentParentId) != -1) {
    			parentChildMap[currentParentId].push(links[i]);
    		} else {
    			//Do nothing;
    		}
    	};


    	var coveredLinks = new Array();
    	var generateMenu = function (parent, links, submenu) {
    		for (var i = 0; i < links.length; i++) {
    			if (coveredLinks.indexOf(links[i].id) > 0) {
    				continue;
    			}
    			coveredLinks.push(links[i].id);
    			if (parentChildMap[links[i].id] == null) {
    				var li;
    				if (submenu == false) {
    					li = '<li id=' + links[i].id + '><a href="#"><i class="' + links[i].class + '"></i><span class="hidden-sm text">' + links[i].name + '</span></a></li>';
    				} else {
    					li = '<li id=' + links[i].id + '><a href="#" class="submenu"><i class="' + links[i].class + '"></i><span class="hidden-sm                             text">' + links[i].name + '</span></a></li>';
    				}
    				parent.append(li);
    			} else {
    				var li = "<li id=" + links[i].id + "></li>";
    				li = parent.append(li).find("#" + links[i].id);
    				li.append('<a class="dropmenu" href="#"><i class="fa fa-folder-o blue"></i><span class="hidden-sm text">' + links[i].name + '</span><span class="chevron closed"></span></a>');
    				var ul = "<ul></ul>";
    				generateMenu(li.append(ul).find("ul"), parentChildMap[links[i].id]);
    			}
    		}
    	}

    	var parent = $("#navigation-links");
    	generateMenu(parent, context.links, false);
    	$("#nav-div").on("click", "li", function (event) {
    		event.stopPropagation();
    		//To Be Improved
    		var urlToLoad = "";
    		var clickedLiId = $(this).attr("id");
    		for (var i = 0; i < links.length; i++) {
    			if (links[i].id == clickedLiId) {
    				urlToLoad = links[i].load;
    				break;
    			}
    		}

    		if (urlToLoad != "") {
    			$("#content").empty();
    			$('#content').load(urlToLoad);
    		}

    	});

    	$(".dropmenu").click(
    		function (t) {
    			t.preventDefault();
    			if ($("#sidebar-left").hasClass("minified")) {
    				if (!$(this).hasClass("open")) {
    					$(this).parent().find("ul").first().slideToggle();
    					$(this).find(".chevron").hasClass("closed") ? $(this).find(".chevron").removeClass("closed").addClass("opened") : $(this).find(".chevron").removeClass("opened").addClass("closed")
    				}
    			} else {
    				$(this).parent().find("ul").first().slideToggle();
    				$(this).find(".chevron").hasClass("closed") ? $(this).find(".chevron").removeClass("closed").addClass("opened") : $(this).find(".chevron").removeClass("opened").addClass("closed")
    			}
    		});
    });